package com.zhiyou100.review.day005.file.test;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @packageName: BaseFileReader
 * @className: com.zhiyou100.review.day005.test
 * @Description: TODO 读取文件类
 * @author: yang
 * @date: 6/13/20
 */
public abstract class BaseFileReader {
    protected Path filePath;

    public BaseFileReader(Path filePath) {
        this.filePath = filePath;
    }

    public List<String> redFiles() throws IOException {
        return Files.lines(filePath)
                .map(this::mapFileLines).collect(Collectors.toList());
    }


    protected abstract String mapFileLines(String line);
}
